import request from "@/api/request";
import common from "@/lib/common";

let baseURL = "";
if (process.env.NODE_ENV === 'production') {
    baseURL = common.server.ipd;
} else {
    baseURL = common.devServer.ipd;
}
export default {
    statusEnums(success, fail) {
        request.get({
            url: `${baseURL}/public/work-report/statusEnums`,
            success: success,
            fail: fail
        })
    },
    typeEnums(success, fail) {
        request.get({
            url: `${baseURL}/public/work-report/typeEnums`,
            success: success,
            fail: fail
        })
    },
    workPage(startDate, endDate, token, success, fail) {
        request.get({
            url: `${baseURL}/my/work-report/page?pageIndex=1&pageSize=1000&currentDateGe=${startDate}&currentDateLe=${endDate}&orderType=2`,
            headers: {
                'token': token,
            },
            success: success,
            fail: fail
        })
    },
    dailyReport(startDate, endDate, token, success, fail) {
        request.get({
            url: `${baseURL}/my/work-report/dailyReport?currentDateGe=${startDate}&currentDateLe=${endDate}`,
            headers: {
                'token': token,
            },
            success: success,
            fail: fail
        })
    },
    deleteByIds(id, token, success, fail) {
        request.post({
            url: `${baseURL}/my/work-report/deleteByIds`,
            headers: {
                'token': token,
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            data: id,
            success: success,
            fail: fail
        })
    },
    updatePosition(form, token, success, fail) {
        request.post({
            url: `${baseURL}/my/work-report/updatePosition`,
            headers: {
                'token': token,
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            data: form,
            success: success,
            fail: fail
        })
    },
    edit(form, token, success, fail) {
        request.post({
            url: `${baseURL}/my/work-report/edit`,
            headers: {
                'token': token,
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            data: form,
            success: success,
            fail: fail
        })
    },
    workTaskPage(form, token, success, fail) {
        request.get({
            url: `${baseURL}/protect/work-task/page`,
            headers: {
                'token': token,
            },
            params: form,
            success: success,
            fail: fail
        })
    },
    myWorkTaskPage(form, token, success, fail) {
        request.get({
            url: `${baseURL}/my/work-task/page`,
            headers: {
                'token': token,
            },
            params: form,
            success: success,
            fail: fail
        })
    },
    projects(form, token, success, fail) {
        request.get({
            url: `${baseURL}/protect/project/page`,
            headers: {
                'token': token,
            },
            params: form,
            success: success,
            fail: fail
        })
    },
    rds(form, token, success, fail) {
        request.get({
            url: `${baseURL}/protect/rd/list`,
            headers: {
                'token': token,
            },
            params: {
                ...form,
                pageSize:1000,
                pageIndex:1
            },
            success: success,
            fail: fail
        })
    },
    myProjects(form, token, success, fail) {
        request.get({
            url: `${baseURL}/my/project/page`,
            headers: {
                'token': token,
            },
            params: form,
            success: success,
            fail: fail
        })
    },
    projectItem(projectId, token, success, fail) {
        request.get({
            url: `${baseURL}/protect/project/item?id=${projectId}`,
            headers: {
                'token': token,
            },
            success: success,
            fail: fail
        })
    },
    key(account, success, fail) {
        request.get({
            url: `${baseURL}/key?username=${account}`,
            success: success,
            fail: fail
        })
    },
    login(account, passd, success, fail) {
        request.post({
            url: `${baseURL}/login`,
            data: {
                username: account,
                password: passd
            },
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            success: success,
            fail: fail
        })
    },
}